<template>
    <div>
        <div class="">
            <h1 class="h2">订单列表</h1>
        </div>
        <div class="table-responsive">
            <table class="table table-striped">
                <thead>
                <tr>
                    <th>省</th>
                    <th>市</th>
                    <th>地区</th>
                    <th>卧室</th>
                    <th>客厅</th>
                    <th>厨房</th>
                    <th>阳台</th>
                    <th>卫生间</th>
                    <th>平方米</th>
                    <th>电话</th>
                </tr>
                </thead>
                <tbody>
                <template v-if="orders.length">
                    <tr v-for="order in orders" :key="order.id">
                        <td>{{order.province}}</td>
                        <td>{{order.city}}</td>
                        <td>{{order.area}}</td>
                        <td>{{order.bedroom}}</td>
                        <td>{{order.livingroom}}</td>
                        <td>{{order.kitchen}}</td>
                        <td>{{order.balcony}}</td>
                        <td>{{order.bathroom}}</td>
                        <td>{{order.sqm}}</td>
                        <td>{{order.phone}}</td>
                    </tr>
                </template>
                </tbody>
            </table>
        </div>
    </div>
</template>

<script>
import OrderServices from '../../services/OrderServices'

export default {
  name: 'OrderList',
  data () {
    return {
      orders: []
    }
  },
  methods: {
    async setOrderList () {
      try {
        const response = await OrderServices.getOrderList()
        this.orders = response.data
      } catch (e) {
        this.error = e.response.data.error
      }
    }
  },
  created: function () {
    // var tk = this.$store.state.token;
    this.setOrderList()
  }
}
</script>

<style scoped>

</style>
